require 'zdc.doc'

module(..., package.seeall)

local ClientMag = {}
local ClientMag_mt = {__metatable = {}, __index = ClientMag}


function new(params)
	local obj = setmetatable({ik=params.ik,logger=params.logger,seapp=params.seapp,_map={}}, ClientMag_mt)
	obj:ClearAll()
	return obj
end

function ClientMag:ClearAll()
	self._map={}
end

function ClientMag:AddTmpOne(accid,cli)
	self._map[accid]=cli
end
function ClientMag:DelTmpOne(accid,cli)
	self._map[accid]=nil
end

function ClientMag:AddOne(accid,cli,ch,bd)
	--TODO: mutil proxy kick out client
	if ch.force then
		local old=self._map[accid]
		if old then
			old:OnClose()
		end
		self._map[accid]=cli
	else
		if self._map[accid] then return nil,"Has login from other addr" end
		self._map[accid]=cli
	end
	return true
end

function ClientMag:DelOne(accid,cli)
	if self._map[accid]~=cli then return end
	self._map[accid]=nil
end

function ClientMag:Find(accid,clip)
	return self._map[accid]
end

